package com.java.netty.common.enums;


public enum PPTPErrCode {
    // 系统级错误
    SYSTEM_ERR(501, "命令不支持"),
    SERVER_ERR(502, "服务器处理错误"),
    SERVER_BUSY_ERR(503, "服务器忙"),
    // 协议错误
    MSG_HEADER_ERR(401, "消息头异常"),
    MSG_FORMAT_ERR(402, "消息体格式异常"),
    PARAMS_ERR(403, "参数错误或缺失"),
    // 不合理的流程或参数
    ENV_NULL_ERR(301, "env信息为空"),
    ENV_LACK_ERR(302, "env信息过少:%s"),
    REG_ERR(303, "注册信息错误:%s"),
    UDID_ERR(303, "udid效验失败"),
    // 信息错误
    SERVID_ERR(201, "不存在的servid或者该servid被禁用"),
    TOKEN_ERR(201, "不正确的token"),
    CHANNEL_ERR(201, "不存在的channel"),
    ;

    Integer code;
    String msg;

    PPTPErrCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    @Override
    public String toString() {
        return String.format("{\"code\":%s,\"msg\":\"%s\"}", code, msg);
    }

    public String toString(String replace) {
        return String.format("{\"code\":%s,\"msg\":\"%s\"}", code, String.format(msg, replace));
    }
}
